<template>
  <!-- 日常 -->
  <div style="width: 100%;margin-bottom: 20px;page-break-before: always;color: #000000;">
    <div v-show="!report" style="display: flex;justify-content: space-between;width: 100%;">
      <div>
        <h2>{{printData.usage}}</h2>
        <span>{{printData.school}}</span>
      </div>
      <div style="text-align: right;">
        <div>日期:{{$moment(printData.date).format('YYYY-MM-DD')=='Invalid date'?printData.date:$moment(printData.date).format('YYYY-MM-DD')}}</div>
        <div v-if="usageId == 1||usageId == 2">学期:{{printData.term}}</div>
        <div v-html="printData.teacher"></div>
        <div>运动项目:{{printData.sport}}</div>
        <div v-if="(usageId == 3||usageId == 4) && printData.scenario">场景:{{printData.scenario}}</div>
      </div>
    </div>
    <hr color="#000000" size="1" v-show="!report">
    <div>
      <div v-show="!report">运动员:{{printData.player}}</div>
      <div v-show="!report">性别:{{printData.gender}}</div>
      <div style="display: flex;justify-content: space-between;">
        <div v-show="!report">出生日期:{{$moment(printData.born).format('YYYY-MM-DD')}}</div>
        <div style="display: flex;align-items: center;">
          <div>备注：</div>
          <div style="width: 20px;height: 20px;background-color: #006633;margin-left:10px;"></div>理想
          <div style="width: 20px;height: 20px;background-color: #f1f1f1;margin-left:10px;"></div>正常
          <div style="width: 20px;height: 20px;background-color: #FFCC33;margin-left:10px;"></div>注意
          <div style="width: 20px;height: 20px;background-color: #FF3300;margin-left:10px;"></div>预警
          <div style="width: 20px;height: 20px;background-color: #990000;margin-left:10px;"></div>告警
          <!-- <div style="width: 20px;height: 20px;background-color: #CCCCCC;margin-left:10px;"></div>错误 -->
        </div>
      </div>
    </div>
    <table class="table" border="1" bordercolor="#000000" style="width: 100%;margin-top: 10px;border-collapse: collapse;text-align: center;color: #000000;">
      <thead>
        <tr style="font-weight: bold;height: 50px;">
          <td width="60px">指标名称</td>
          <td width="100px" v-if="usageId == 3||usageId == 4">检测时间</td>
          <td width="60px">检测值</td>
          <td width="60px">单位</td>
          <td width="100px" v-if="usageId == 3||usageId == 4">参考值</td>
          <td width="60">预警级别</td>
          <td width="60px" v-if="usageId == 3||usageId == 4">检测结果</td>
          <td v-if="usageId == 1||usageId == 2" width="60">得分</td>
          <td>{{usageId == 1||usageId == 2?'主观评定':'评价'}}</td>
          <td v-if="usageId == 1||usageId == 2" width="40">等级</td>
        </tr>
      </thead>
      <tbody>
        <tr style="height: 50px;" v-for="item,index in printData.data" :key="index">
          <td>{{item.meta}}</td>
          <td v-if="usageId == 3||usageId == 4">{{$moment(printData.date).format('YYYY-MM-DD')}}</td>
          <td>{{item.value}}</td>
          <td>{{item.unit}}</td>
          <td v-if="usageId == 3||usageId == 4">{{item.refval}}</td>
          <td :bgcolor="dict_bgColor[item.warnLevel]" style="color: #000000;">{{item.warnLevel}}</td>
          <td v-if="usageId == 3||usageId == 4">{{item.resultName}}</td>
          <td v-if="usageId == 1||usageId == 2">{{item.score==0?'':item.score}}</td>
          <td style="font-size: 80%;">{{item.diagnosis}}</td>
          <td v-if="usageId == 1||usageId == 2">{{item.level==0?'':dict_level[item.level]}}</td>
        </tr>
        <tr v-if="usageId == 1||usageId == 2" style="height: 40px;">
          <td>得分等级</td>
          <td colspan="4">优秀：80~100分 良好：60~80分 及格：30~60分 不及格：0~30分</td>
          <td>总得分：</td>
          <td colspan="2">{{sum}}</td>
        </tr>
      </tbody>
    </table>
    <div v-show="analysisReport" style="display: flex;margin-top: 10px;">
      <div style="margin-right: 20px;">评价:</div>
      <div v-html="printData.memo || memo"></div>
    </div>
  </div>
</template>

<script>
  export default {
    props: ['printData','usageId','report','memo','analysisReport'],
    data() {
      return {
        dict_bgColor: {
        	"理想": "#006633",
        	"正常": "#ffffff",
        	"注意": "#FFCC33",
        	"预警": "#FF3300",
        	"告警": "#990000",
        	"": "#fff",
        	" ": "#fff"
        },
        dict_level: {
            "1": "一等",
            "2": "二等",
            "3": "三等",
            "4": "四等",
            "5": "五等",
            "0": "",
            " ": "",
            "": "",
        }
      }
    },
    computed: {
      sum() {
        let sum = null
        this.printData.data.forEach(item=>{
          if(item.score){
            sum += parseFloat(item.score)
          }else{
            sum += 0
          }
        })
        return sum.toFixed(2)
      }
    }
  }
</script>

<style scoped>

</style>
